package www.rlicker.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import www.rlicker.dao.IParameterDao;
import www.rlicker.model.Parameter;
import www.rlicker.mybatis.Criteria;
import www.rlicker.service.IParameterService;
import www.rlicker.utils.MessageConstant;
import www.rlicker.utils.TranslateToMap;

@Service
public class ParameterServiceImpl implements IParameterService{

	@Override
	public List<Map<String, Object>> queryPage(Criteria<Parameter> param) {
		List<Parameter> list = parameterDao.queryPage(param);
		List<Map<String,Object>> map = TranslateToMap.convertListBean2ListMap(list,Parameter.class);
	return map;  }

	@Override
	public Integer queryPageCount(Criteria<Parameter> param) {
		return (Integer) parameterDao.queryPageCount(param);
	}

	@Override
	public Parameter queryEntity(Long id) {
		return parameterDao.queryEntity(id);
	}

	@Override
	public String deleteById(Long id) {
		int result = parameterDao.deleteById(id);
		if ( result != 1) {
				return MessageConstant.USER_TYPE_3;
		}
		return null;
	}

	@Override
	public String insert(Parameter record) {
		int result = parameterDao.insert(record);
		if ( result != 1) { 
				return MessageConstant.USER_TYPE_4;
		}
		return null;
	}

	@Override
	public String update(Criteria<Parameter> param) {
		int result = parameterDao.update(param);
		if ( result != 1) { 
				return MessageConstant.USER_TYPE_5;
		}
		return null;
	}
	
	@Resource
	private IParameterDao parameterDao;

	@Override
	public List<Parameter> queryPageList(Criteria<Parameter> param) {
		return parameterDao.queryPage(param);
	}

}
